import { defineComponent } from 'vue'
import { useRoute, useRouter } from 'vue-router'

export default defineComponent({
  name: 'Redirect',
  setup() {
    const route = useRoute()
    const router = useRouter()

    const { params, query } = route
    const path = params.path as string

    router.replace({
      path: path.startsWith('/') ? path : `/${path}`,
      query
    })
  },
  render() {
    return <div></div>
  }
})
